<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			let stus = []
			function loadStus(){
				let xhr = new XMLHttpRequest()
				xhr.open("GET","stu.xml",false)
				xhr.send()
				let data = xhr.responseXML
				stus = data.getElementsByTagName("student")
				document.querySelector(".s1").value = stus[0].getAttribute("sno")
				document.getElementsByClassName("s2")[0].value = stus[0].getAttribute("sname")
			}
			let index = 0;
			function next(){
				index++
				document.querySelector(".s1").value = stus[index%stus.length].getAttribute("sno")
				document.getElementsByClassName("s2")[0].value = stus[index%stus.length].getAttribute("sname")
			}
		</script>
	</head>
	<body onload="loadStus()">
		学号：<input type="text" class="s1"/><br>
		姓名：<input type="text" class="s2"><br>
		<button type="button" onclick="next()">下一个</button>
	</body>
</html>
